-- artifact_scrap
-- created by limj
-- 道具描述：神器碎片

return {
    -- 获取道具描述
    getDesc = function(itemId, args, para)
        local desc       = getLocStr("script_desc_artifact_scrap1");
        local artiId     = ArtifactM.getArtifactByScrap(itemId);
        local artiName   = ItemM.query(artiId, "name");
        local ret        = ArtifactM.canUpgrade(artiId);
        local ownAmount  = ItemM.getAmount(ME.user, itemId);
        local needAmount;
        local exDesc;

        -- 玩家是否拥有神器
        if ret == "artifact_not_exist" then
            -- 神器不存在
            local compoundCost = ArtifactM.getCompoundCost(artiId);

            for _, arr in pairs(compoundCost) do
                if arr[1] == 1 and arr[2] == itemId then
                    needAmount = arr[3];
                    break;
                end
            end
            exDesc = string.format(getLocStr("script_desc_artifact_scrap2"), artiName, ownAmount, needAmount);
        elseif ret == "hint_reach_max_level" then
            -- 神器等级到最高级
            exDesc = string.format(getLocStr("script_desc_artifact_scrap4"), artiName);
        else
            -- 神器未到最高等级
            local upgradeCost = ArtifactM.getUpgradeCost(artiId, "scarpNeed");

            for _, arr in pairs(upgradeCost) do
                if arr[1] == 1 and arr[2] == itemId then
                    needAmount = arr[3];
                    break;
                end
            end
            exDesc = string.format(getLocStr("script_desc_artifact_scrap3") .. getLocStr("script_desc_artifact_scrap4"),
                                    artiName, ownAmount, needAmount, artiName);
        end

        desc = string.format("%s\n%s", desc, exDesc);

        return desc;
    end,
};
